/*

% Description of my shader.
% Second line of description for my shader.

keywords: material classic

date: YYMMDD

*/

//Matrices
float4x4 WorldViewProj : WorldViewProjection;

//Structures de données
struct AppInput{
    float3 position : POSITION;
    float2 texCoordinates : TEXCOORD0;
};

struct VertexToPixel{
    float4 position : POSITION;
    float2 texCoordinates : TEXCOORD0;
};

//Textures
Texture coloredTexture : Diffuse
<
    string ResourceType = "2D";
    string UIName = "Texture";
>;

sampler coloredTextureSampler = sampler_state{
            texture = <coloredTexture>;
            magfilter = LINEAR;
            minfilter = LINEAR;
            mipfilter = LINEAR;
            };
            
//Vertex shader            
VertexToPixel mainVS(AppInput input){
    //Structure à retourner
    VertexToPixel output = (VertexToPixel)0;
    
    //Remplissage des éléments de la structure
    output.position = mul(float4(input.position, 1.0), WorldViewProj);  //Position
    output.texCoordinates = input.texCoordinates;               
    
    //Renvoi de la structure
    return output;
}

//Pixel shader
float4 mainPS(VertexToPixel input) : COLOR{
    return tex2D(coloredTextureSampler, input.texCoordinates);                                            
}

technique technique0 {
	pass p0 {
		VertexShader = compile vs_2_a mainVS();
		PixelShader = compile ps_2_a mainPS();
	}
}
